package org.tvolkov.mycompany



import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.web.ControllerUnitTestMixin} for usage instructions
 */
@TestFor(AppController)
class AppControllerTests {

	void testGetCompany(){
		params.node = "root";
		controller.get();
		assertEquals "/company/list", response.redirectedUrl;
	}
	
	void testGetDivision(){
		params.node = "company";
		controller.get();
		assertEquals "/division/list", response.redirectedUrl;
	}
	
	void testGetProject(){
		params.node = "division";
		controller.get();
		assertEquals "/project/list", response.redirectedUrl;
	}
	
	void testGetEmployee(){
		params.node = "project";
		controller.get();
		assertEquals "/employee/list", response.redirectedUrl;
	}
	
	void testAddCompany(){
		params.parentNode = "root";
		controller.add();
		assertEquals "/company/add?parentNode=root", response.redirectedUrl;
	}
	
	void testRemoveCompany(){
		params.node = "company1";
		controller.remove();
		assertEquals "/company/remove?nodeid=1", response.redirectedUrl;
	}
	
	void testDetailsCompany(){
		params.nodeid = "company1";
		controller.details();
		assertEquals "/company/details?nodeid=1", response.redirectedUrl;
	}
	
	void testEditCompany(){
		params.nodeid = "company1";
		controller.edit();
		assertEquals "/company/edit?nodeid=1", response.redirectedUrl;
	}
}
